package com.dcc.controller;

import com.dcc.bean.ClassBean;
import com.dcc.bean.SchoolBean;
import com.dcc.bean.UserBean;
import com.dcc.bean.returnBean.IsOk;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(value = "Controller", tags = "哈喽")
// value可有可无
// tags 表示类的注释
@ApiIgnore
public class UserController {
    @ApiOperation(value = "你好啊",notes = "第一次访问swagger",httpMethod = "GET")
    // value 表示接口作用，
    // notes 表示接口详情，
    // httpMethod 指定接口请求方式，如果和下面的请求方式不一致，报错；先写api注解，再写下面请求方式
    @GetMapping ("/hello2")
    public String hello(@RequestBody UserBean userBean) { //实体类必须在此使用后才能显示出来
        return "您输入的姓名是：" + userBean.getName() + ";\n"
             + "您输入的年龄是：" + userBean.getAge() + ";\n"
             + "您输入的身高是：" + userBean.getHeight();
    }

    @ApiOperation(value = "实体类", notes = "返回OK", httpMethod = "GET")
    @GetMapping("/getOk")
    public IsOk getOk(){
        return IsOk.getInstance();
    }

    @ApiOperation(value = "返回类", notes = "试一下返回值是实体类的话，文档中会不会显示", httpMethod = "GET")
    @GetMapping("/getSchool")
    public SchoolBean getSchool(){
        SchoolBean schoolBean = new SchoolBean();
        schoolBean.setSchoolName("南台头小学");
        schoolBean.setSchoolAddress("河北省邯郸市魏县北台头乡男台头村");
        return schoolBean;
    }

    @ApiOperation(value = "返回类", notes = "试一下返回值是实体类的话，但是不在控制层新建，文档中会不会显示", httpMethod = "GET")
    @GetMapping("/getClassBean")
    public ClassBean getClassBean(){
        return IsOk.getClassBean();
    }


}
